# encoding: UTF-8
"""

@author = 李林名
@email = lishuai1199@qq.com
@create_time = 2022/11/24 19:11

"""

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

#1.获取confirm信息并点击Cancle
wd = webdriver.Chrome()
wd.get('https://cdn2.byhy.net/files/selenium/test4.html')
##点击confirm元素
element=wd.find_element(By.CSS_SELECTOR,'#b2')
element.click()
##获取confirm提示信息
alertTxt=wd.switch_to.alert.text
print("alertTxt信息:",alertTxt)
sleep(1)

##点击confirm的Cancle
wd.switch_to.alert.dismiss()
sleep(2)